package org.jing.ext.pdf.itextpdf;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.pdf.BaseFont;

/**
 * Description: <br>
 *
 * @author bks <br>
 * @since 2021-02-04 <br>
 */
@SuppressWarnings({ "WeakerAccess", "unused", "UnusedReturnValue" }) public class DataRow {
    private String key;

    private String value = "";

    private BaseFont fontStyle = null;

    private BaseColor fontColor = null;

    private float fontSize = -1;

    public DataRow(String key) {
        this.key = key;
    }

    public DataRow(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public DataRow(String key, String value, BaseFont fontStyle, BaseColor fontColor, float fontSize) {
        this.key = key;
        this.value = value;
        this.fontStyle = fontStyle;
        this.fontColor = fontColor;
        if (-1 < fontSize) {
            this.fontSize = fontSize;
        }
    }

    public String getKey() {
        return key;
    }

    public DataRow setKey(String key) {
        this.key = key;
        return this;
    }

    public String getValue() {
        return value;
    }

    public DataRow setValue(String value) {
        this.value = value;
        return this;
    }

    public BaseFont getFontStyle() {
        return fontStyle;
    }

    public DataRow setFontStyle(BaseFont fontStyle) {
        this.fontStyle = fontStyle;
        return this;
    }

    public DataRow setFontStyle(String fontString) {
        this.fontStyle = FontFactory.getFont(fontString, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED,28f, Font.NORMAL, BaseColor.BLACK).getBaseFont();
        return this;
    }


    public BaseColor getFontColor() {
        return fontColor;
    }

    public DataRow setFontColor(BaseColor fontColor) {
        this.fontColor = fontColor;
        return this;
    }

    public DataRow setFontColor(int r, int g, int b) {
        this.fontColor = new BaseColor(r, g, b);
        return this;
    }

    public float getFontSize() {
        return fontSize;
    }

    public DataRow setFontSize(float fontSize) {
        this.fontSize = fontSize;
        return this;
    }

    @Override public String toString() {
        return String.format("<%s, %s>", key, value);
    }
}
